package com.guigu.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.pojo.CommentOnCommodity;
import com.guigu.service.CommentOnCommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@CrossOrigin
@RestController
@RequestMapping("/commodity/")
public class CommentOnCommodityController {

    @Autowired
    CommentOnCommodityService commodityService;

    //添加评价表
    @PostMapping("commodity.action")
    public Map addCommodity(@RequestBody CommentOnCommodity commodity){
        return commodityService.addCommodity(commodity);
    }

    //查询评价表
    @GetMapping("commodity.action")
    public Page<CommentOnCommodity> queryAllComment(CommentOnCommodity comment,
                                                    @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                                    @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return  commodityService.queryAllComment(comment,pageno,pagesize);
    }
}
